layui.use(['customUtil'], function (customUtil) {


    var seckillDetails = {

        _constant: {
            api: {
                doSeckill: appCtx + '/seckill/seckillByCache',
            }
        },

        _init: function () {
            let _this = this;
            _this._bind();
        },

        _bind: function () {
            let _this = this;
            $("#seckillButton").on("click", function () {
                _this._doSeckill();
            });
        },

        _doSeckill: function () {
            let _this = this;
            let data = {
                seckillId: $("#seckillGoodsId").val()
            };
            customUtil.post(_this._constant.api.doSeckill, data, function (data) {
                if (data.success) {
                    if (data.result)
                        layer.msg(data.result.msg);
                } else {
                    alert(data.messages);
                    layer.alert(data.messages, {
                        title: '操作失败'
                    })
                }
            });
        }

    };

    seckillDetails._init();

});